const App = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    let params = {
      page: 1,
      pageSize: 10,
    }
    App.HttpService.getFavoriteByUser(params).then(res => {
      console.log(params)
      this.setData({
        activityList: res.data.data.selfYanFavoriteList,
        paginate: res.data.data.paginate
      })
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },
  navigaToActiveDetail(e) {
   
    App.WxService.navigateTo("/pages/goods/detail/detail", {
      goodsId: e.currentTarget.dataset.id
    })
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {
    if (!this.data.paginate.hasNext) {
      return
    }
    let params = {
      page: this.data.paginate.next,
      pageSize: this.data.paginate.perPage,
    }
    App.HttpServiceNoToast.getFavoriteByUser(params).then(res => {
      console.log(res)
      this.setData({
        activityList: res.data.data.selfYanFavoriteList,
        paginate: res.data.data.paginate
      })

      if (res.data.data.selfCommentList) {
        this.data.activityList = [...this.data.activityList, ...res.data.data.selfYanFavoriteList]
      }
      this.setData({
        activityList: this.data.selfYanFavoriteList,
        paginate: res.data.data.paginate,
        isHave: this.data.selfYanFavoriteList.length > 0
      })

    })

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  }
})